package com.stock.controller;

import com.stock.entity.NewStockDataEntity;
import com.stock.service.IAdminService;
import com.stock.vo.ResultVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/admin")
@CrossOrigin(origins = "*")
@ApiIgnore
public class AdminController {

    private final IAdminService adminService;

    public AdminController(IAdminService adminService) {
        this.adminService = adminService;
    }

    @PostMapping("/setNewStockData")
    @ApiOperation("设置最新持仓")
    public ResultVo setNewStockData(@RequestBody NewStockDataEntity entity) {
        return ResultVo.success(adminService.setNewStockData(entity));
    }

    @GetMapping("/initHistoryStockData")
    @ApiOperation("初始化历史数据")
    public ResultVo initHistoryStockData() {
        return ResultVo.success(adminService.initHistoryStockData());
    }

    @GetMapping("/initStockProfitData")
    @ApiOperation("初始化股票收益数据")
    public ResultVo initStockProfitData() {
        return ResultVo.success(adminService.initStockProfitData());
    }

}
